#ifdef FSHIGHPRECISION
	precision highp float;
#else
	precision mediump float;
#endif

struct DirectionLight
{
	vec3 Color;
	vec3 Direction;
};
uniform DirectionLight u_DirectionLight;

varying vec2 v_Texcoord0;
varying vec4 v_Color;
varying vec3 v_ViewDir; 
varying vec3 v_Normal;

void LayaAirBlinnPhongDiectionLight (in vec3 normal, in vec3 viewDir, in DirectionLight light,out vec3 diffuseColor)
{
	vec3 lightVec = normalize(light.Direction);
	
	//mediump vec3 h = normalize(viewDir-light.Direction);
	//float nh = max (0.0, dot (h,normal));
	
    lowp float ln = max (0.0, dot (-lightVec,normal));
	diffuseColor = light.Color * ln;
}

void main()
{
	vec3 diffuseColor;
	vec3 normal = normalize(v_Normal);
	vec3 viewDir = normalize(v_ViewDir);
	LayaAirBlinnPhongDiectionLight(normal, viewDir, u_DirectionLight, diffuseColor);
	
	gl_FragColor.xyz = diffuseColor * v_Color.xyz * 2.0;
}

